﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QLTV_Public;
using System.Data;

namespace QLTV_Data
{
   public class DocGia_Data
    {
       KetNoiCSDL_Data kn = new KetNoiCSDL_Data();

       public DataTable TaoBang(string sql)
       {
           return kn.taobang(sql);
       }
       public DataTable LayDuLieu()
       {
           return kn.LayDuLieu("Load_DocGia");
       }
       public DataTable Load_DocGia_GiaoVien(string maDocGia,string hoVaTen,Boolean isNgaySinh,DateTime ngaySinh,Boolean isNgayLamThe,DateTime fromNgayLamThe,DateTime toNgayLamThe,Boolean isNgayHetHan,DateTime fromNgayHetHan,DateTime toNgayHetHan)
       {
           int Npara = 10;
           string[] name = new string[Npara];
           object[]value=new object[Npara];
           name[0] = "@MaDocGia";
           value[0] = maDocGia;
           name[1] = "@HoVaTen";
           value[1] = hoVaTen;
           name[2] = "@isNgaySinh";
           value[2] = isNgaySinh;
           name[3] = "@NgaySinh";
           value[3] = ngaySinh;
           name[4] = "@isNgayLamThe";
           value[4] = isNgayLamThe;
           name[5] = "@FromNgayLamThe";
           value[5] = fromNgayLamThe;
           name[6] = "@ToNgayLamThe";
           value[6] = toNgayLamThe;
           name[7] = "@isNgayHetHan";
           value[7] = isNgayHetHan;
           name[8] = "@FromNgayHetHan";
           value[8] = fromNgayHetHan;
           name[9] = "@ToNgayHetHan";
           value[9] = toNgayHetHan;
           //name[10] = "@TrangThaiSuDung";
           //value[10] = trangThaiSD;

           return kn.LayDuLieu("Load_DocGia_GiaoVien",name,value,Npara);
       }
       public DataTable Load_DocGia_HocVien(string maDocGia, string hoVaTen, Boolean isNgaySinh, DateTime ngaySinh, Boolean isNgayLamThe, DateTime fromNgayLamThe, DateTime toNgayLamThe, Boolean isNgayHetHan, DateTime fromNgayHetHan, DateTime toNgayHetHan)
       {
           int Npara = 10;
           string[] name = new string[Npara];
           object[] value = new object[Npara];
           name[0] = "@MaDocGia";
           value[0] = maDocGia;
           name[1] = "@HoVaTen";
           value[1] = hoVaTen;
           name[2] = "@isNgaySinh";
           value[2] = isNgaySinh;
           name[3] = "@NgaySinh";
           value[3] = ngaySinh;
           name[4] = "@isNgayLamThe";
           value[4] = isNgayLamThe;
           name[5] = "@FromNgayLamThe";
           value[5] = fromNgayLamThe;
           name[6] = "@ToNgayLamThe";
           value[6] = toNgayLamThe;
           name[7] = "@isNgayHetHan";
           value[7] = isNgayHetHan;
           name[8] = "@FromNgayHetHan";
           value[8] = fromNgayHetHan;
           name[9] = "@ToNgayHetHan";
           value[9] = toNgayHetHan;
           //name[10] = "@TrangThaiSuDung";
           //value[10] = trangThaiSD;
           return kn.LayDuLieu("Load_DocGia_HocVien",name,value,Npara);
       }
       public int Insert(DocGia_Public docGia)
       {
           int para = 6;
           string[]name=new string[para];
           object[] value = new object[para];

           name[0] = "@MaDocGia";
           value[0] = docGia.MaDocGia;
           name[1] = "@NgayLamThe";
           value[1] = docGia.NgayLamThe;
           name[2] = "@NgayHetHan";
           value[2] = docGia.NgayHetHan;
           name[3] = "@MaLoaiThe";
           value[3] = docGia.MaLoaiThe;
           name[4] = "@TrangThaiSD";
           value[4] = docGia.TrangThaiSD;
           name[5] = "@MaNhanVien";
           value[5] = docGia.MaNhanVien;

           return kn.update("Insert_DocGia",name,value,para);
       }
       public int Update(DocGia_Public docGia)
       {
           int para = 6;
           string[]name=new string[para];
           object[] value = new object[para];

           name[0] = "@MaDocGia";
           value[0] = docGia.MaDocGia;
           name[1] = "@NgayLamThe";
           value[1] = docGia.NgayLamThe;
           name[2] = "@NgayHetHan";
           value[2] = docGia.NgayHetHan;
           name[3] = "@MaLoaiThe";
           value[3] = docGia.MaLoaiThe;
           name[4] = "@TrangThaiSD";
           value[4] = docGia.TrangThaiSD;
           name[5] = "@MaNhanVien";
           value[5] = docGia.MaNhanVien;

           return kn.update("Update_DocGia",name,value,para);
       }
       public int Delete_DocGia_HocVien(string maDocGia)
       {
           int para = 1;
           string[] name = new string[para];
           object[] value = new object[para];

           name[0] = "@MaDocGia";
           value[0] = maDocGia;

           return kn.update("Delete_DocGia_HocVien", name, value, para);
       }
       public int Delete_DocGia_GiaoVien(string maDocGia)
       {
           int para = 1;
           string[] name = new string[para];
           object[] value = new object[para];

           name[0] = "@MaDocGia";
           value[0] = maDocGia;

           return kn.update("Delete_DocGia_GiaoVien", name, value, para);
       }
       public DataTable Load_Muon_SinhVien(PhieuYeuCau_Public obj, string hoTen, DateTime toNgayLapPhieu)
       {
           int Npara = 4;
           string[] name = new string[Npara];
           object[] value = new object[Npara];
           name[0] = "@MaDocGia";
           value[0] = obj.MaDocGia;
           name[1] = "@HoVaTen";
           value[1] = hoTen;
           name[2] = "@FromNgayLapPhieu";
           value[2] = obj.NgayLapPhieu;
           name[3] = "@ToNgayLapPhieu";
           value[3] = toNgayLapPhieu;
           return kn.LayDuLieu("Load_Muon_SinhVien", name, value, Npara);
       }
       public DataTable Load_GiaoVien(PhieuYeuCau_Public obj,string hoTen,DateTime toNgayLapPhieu)
       {
           int Npara = 4;
           string[]name=new string[Npara];
           object[] value = new object[Npara];
           name[0] = "@MaDocGia";
           value[0] = obj.MaDocGia;
           name[1] = "@HoVaTen";
           value[1] = hoTen;
           name[2] = "@FromNgayLapPhieu";
           value[2] = obj.NgayLapPhieu;
           name[3] = "@ToNgayLapPhieu";
           value[3] = toNgayLapPhieu;
           return kn.LayDuLieu("Load_GiaoVien",name,value,Npara);
       }
       public int Update_GiaHanThe(DocGia_Public obj)
       {
           int Npara = 2;
           string[] name = new string[Npara];
           object[] value = new object[Npara];
           name[0] = "@MaDocGia";
           value[0] = obj.MaDocGia;
           name[1] = "@NgayHetHan";
           value[1] = obj.NgayHetHan;

           return kn.update("Update_GiaHanThe",name,value,Npara);
       }
    }
}
